package com.szyibei.system.gateway.controller;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSON;
import com.szyibei.system.common.utils.LoggerUtil;
import com.szyibei.system.common.vo.RequestBaseVO;

import lombok.extern.slf4j.Slf4j;

@RestController
@RefreshScope
@Slf4j
public class TestController {

    @RequestMapping("/test")
    public Map<String, String> hello() {
        Map<String, String> mp = new HashMap<>();
        mp.put("1", "hello");
        mp.put("2", "hi");
        LoggerUtil.info(log, "testgateway返回:{}", mp);
        return mp;

    }

//    @Autowired
//    UserConfig userConfig;

    //      @Autowired
    //      private NacosConfigManager nacosConfigManager;

    @Value("${user.name}")
    String userName;

    @Value("${user.age:25}")
    Integer age;

    @RequestMapping("/user")
    public String simple() {
        return "Hello Nacos Config!" + "Hello " + userName + " " + age /*+ " [UserConfig]: " + userConfig*/;
    }


    public static void main(String[] args) {
        RequestBaseVO vo = new RequestBaseVO();
        vo.setAppid("2020202002");
        vo.setChannel("alipay");
        vo.setServiceCode("nacos-provider-auth");
        vo.setCharset("UTF-8");
        vo.setFormat("NONE");
        System.out.println(JSON.toJSONString(vo));
    }
}
